import execjs
import requests

cookies = {
    'mtop_partitioned_detect': '1',
    '_m_h5_tk': '7d7564c951269159390badc52b6edfb7_1742957099040',
    '_m_h5_tk_enc': 'e7e551765a0d34afedf81767e6f2dd58',
    'thw': 'xx',
    'cna': 'LYhpIIoYOmMBASQJih6d1U9c',
    't': 'ea6da52dda6bf4d75a709e5cb09e3675',
    '_tb_token_': 'eb5133f7933e7',
    'cookie2': '18ac00de5072ac53380df9ae2727b2ed',
    'xlly_s': '1',
    '_samesite_flag_': 'true',
    '3PcFlag': '1742949999776',
    'x5sec': '7b22733b32223a2262383764376161313563663637333737222c22617365727665723b33223a22307c434e692b6a62384745506268354b51454d504c2f384b7746227d',
    'tfstk': 'g7Eoei29Lzu7PZCxkoi5WePUwm_AN0iIsWKK9DhFujlXyDQ7pv40CWcRdai8oXV4ib-RF8FmLW2QyTgdNpv7m5xp2__7LHmKY1COXGe7eDiF6W7Xe2dSBYDPvbuU30MpeNl4RGe7FKJkTOUVXBDuu_Gy8XPE0qkEUDkELXWmuAHEY3ue4ERqGjoELY8y3-kiKUlEaWyVnvGqLHPEztmqGvkUPal7YorVg3mqlBFHhzkorfyra8e803uyP8ccFTE0oPGNXjxeYoDuHhdKxhbK_PG-WqVVD3m33vV-M5Swmmug5JH3Zgxr2rzbV0EAsdgutb3aDqj2ixq0BPkbnNX0nkco7uuDphwjqvPE-r1MXYm8oVquP9O4U5hu70wpI_emSr0s3qJHz0UTBkga4gAsMVM3wjFNbnmq8g8DuF72FHMVpo8BR4kjnfEXS3W50Kbr8tXD79grhYGOntYBR4kjnfBcnFSIzxMS6',
    'isg': 'BOnpyDDpqvvo8ZZOYaVQsF98-JVDtt3otTDmJIvemlJcUghk0wSiuZcEFPbkSnUg',
}

headers = {
    'accept': '*/*',
    'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
    'referer': 'https://uland.taobao.com/sem/tbsearch?clk1=9716da13ed72d1520aba49dae6960ab5&keyword=%E6%97%A5%E7%94%A8%E5%93%81&localImgKey=&msclkid=a2068976d250137414ecee958b310a79&page=1&q=%E6%97%A5%E7%94%A8%E5%93%81&refpid=mm_2898300158_3078300397_115665800437&tab=all&upsId=9716da13ed72d1520aba49dae6960ab5',
    'sec-ch-ua': '"Chromium";v="134", "Not:A-Brand";v="24", "Microsoft Edge";v="134"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'script',
    'sec-fetch-mode': 'no-cors',
    'sec-fetch-site': 'same-site',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36 Edg/134.0.0.0',
    # 'cookie': 'mtop_partitioned_detect=1; _m_h5_tk=7d7564c951269159390badc52b6edfb7_1742957099040; _m_h5_tk_enc=e7e551765a0d34afedf81767e6f2dd58; thw=xx; cna=LYhpIIoYOmMBASQJih6d1U9c; t=ea6da52dda6bf4d75a709e5cb09e3675; _tb_token_=eb5133f7933e7; cookie2=18ac00de5072ac53380df9ae2727b2ed; xlly_s=1; _samesite_flag_=true; 3PcFlag=1742949999776; x5sec=7b22733b32223a2262383764376161313563663637333737222c22617365727665723b33223a22307c434e692b6a62384745506268354b51454d504c2f384b7746227d; tfstk=g7Eoei29Lzu7PZCxkoi5WePUwm_AN0iIsWKK9DhFujlXyDQ7pv40CWcRdai8oXV4ib-RF8FmLW2QyTgdNpv7m5xp2__7LHmKY1COXGe7eDiF6W7Xe2dSBYDPvbuU30MpeNl4RGe7FKJkTOUVXBDuu_Gy8XPE0qkEUDkELXWmuAHEY3ue4ERqGjoELY8y3-kiKUlEaWyVnvGqLHPEztmqGvkUPal7YorVg3mqlBFHhzkorfyra8e803uyP8ccFTE0oPGNXjxeYoDuHhdKxhbK_PG-WqVVD3m33vV-M5Swmmug5JH3Zgxr2rzbV0EAsdgutb3aDqj2ixq0BPkbnNX0nkco7uuDphwjqvPE-r1MXYm8oVquP9O4U5hu70wpI_emSr0s3qJHz0UTBkga4gAsMVM3wjFNbnmq8g8DuF72FHMVpo8BR4kjnfEXS3W50Kbr8tXD79grhYGOntYBR4kjnfBcnFSIzxMS6; isg=BOnpyDDpqvvo8ZZOYaVQsF98-JVDtt3otTDmJIvemlJcUghk0wSiuZcEFPbkSnUg',
}

params = {
    'jsv': '2.7.2',
    'appKey': '12574478',
    't': '1742954411755',
    'sign': 'bfc0b6e73ead67dee3f9f4f696e9a13c',
    'api': 'mtop.relationrecommend.wirelessrecommend.recommend',
    'v': '2.0',
    'type': 'jsonp',
    'dataType': 'jsonp',
    'callback': 'mtopjsonp9',
    'data': '{"appId":"43356","params":"{\\"device\\":\\"HMA-AL00\\",\\"isBeta\\":\\"false\\",\\"grayHair\\":\\"false\\",\\"from\\":\\"nt_history\\",\\"brand\\":\\"HUAWEI\\",\\"info\\":\\"wifi\\",\\"index\\":\\"4\\",\\"rainbow\\":\\"\\",\\"schemaType\\":\\"auction\\",\\"elderHome\\":\\"false\\",\\"isEnterSrpSearch\\":\\"true\\",\\"newSearch\\":\\"false\\",\\"network\\":\\"wifi\\",\\"subtype\\":\\"\\",\\"hasPreposeFilter\\":\\"false\\",\\"prepositionVersion\\":\\"v2\\",\\"client_os\\":\\"Android\\",\\"gpsEnabled\\":\\"false\\",\\"searchDoorFrom\\":\\"srp\\",\\"debug_rerankNewOpenCard\\":\\"false\\",\\"homePageVersion\\":\\"v7\\",\\"searchElderHomeOpen\\":\\"false\\",\\"search_action\\":\\"initiative\\",\\"sugg\\":\\"_4_1\\",\\"sversion\\":\\"13.6\\",\\"style\\":\\"list\\",\\"ttid\\":\\"600000@taobao_pc_10.7.0\\",\\"needTabs\\":\\"true\\",\\"areaCode\\":\\"CN\\",\\"vm\\":\\"nw\\",\\"countryNum\\":\\"156\\",\\"m\\":\\"pc_sem\\",\\"page\\":2,\\"n\\":48,\\"q\\":\\"%E6%97%A5%E7%94%A8%E5%93%81\\",\\"qSource\\":\\"url\\",\\"pageSource\\":\\"\\",\\"tab\\":\\"all\\",\\"pageSize\\":\\"48\\",\\"totalPage\\":\\"100\\",\\"totalResults\\":\\"31598\\",\\"sourceS\\":\\"0\\",\\"sort\\":\\"_coefp\\",\\"filterTag\\":\\"\\",\\"service\\":\\"\\",\\"prop\\":\\"\\",\\"loc\\":\\"\\",\\"start_price\\":null,\\"end_price\\":null,\\"startPrice\\":null,\\"endPrice\\":null,\\"p4pIds\\":\\"731892702365,877486689485,731529741369,803509271107,826459491214,760463763783,851567822331,823229782518,737598139195,675537649268,828182499935,786169662805,746063416131,746019468127,876995763529,880413866209,733117305119,781644247645,820911862002,836509053153,833196145052,803309037378,672745156848,894098005586,842852339158,884532370915,779550903590,865762228498,888201152041,811164149421,821271147752,528345477148,861259930848,602951105048,734599940833,793516294299,739166230313,708152611027,846162459111,797006247517,727771939030,742409908757,603840488124,829885434122,729439695444,779561750760,729097286078,782391642357,817519633264,829524027062,760322200688,769347346776,824785054601,778126306637,743533087782,702247435880,842911234636,745763215446,591502662928,793023141935,678126319711,864409256651,882212158359,859873748199,780512526773,776814193188,710798474051,813174761683,684914093373\\",\\"categoryp\\":\\"\\",\\"myCNA\\":\\"LYhpIIoYOmMBASQJih6d1U9c\\",\\"clk1\\":\\"9716da13ed72d1520aba49dae6960ab5\\",\\"refpid\\":\\"mm_2898300158_3078300397_115665800437\\"}"}',
}
# with open('taoBao.js', 'r', encoding='utf-8') as f:
#     js_code = f.read()
#     params['sign'],params['t'] = execjs.compile(js_code).call('data', params['data'])
#     print(params)
response = requests.get(
    'https://h5api.m.taobao.com/h5/mtop.relationrecommend.wirelessrecommend.recommend/2.0/',
    params=params,
    cookies=cookies,
    headers=headers,
)
print(response.text)